﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Reflection;

namespace MotoCommon
{

    public class MyUtility
    {
        private MyUtility()
        {
        }

        /// <summary>
        /// 为窗口提供居中屏幕的Location
        /// </summary>
        /// <returns>Point对象</returns>
        public static Point CenterWindow(Form form)
        {
            int iSW = Screen.PrimaryScreen.WorkingArea.Width;
            int iSH = Screen.PrimaryScreen.WorkingArea.Height;

            return new Point((iSW - form.Width) / 2, (iSH - form.Height) / 2);
        }

        /// <summary>
        /// 判断是否为int
        /// </summary>
        /// <returns>如果是返回True,否则返回False.</returns>
        public static bool IsInt(string sValue)
        {
            try
            {
                int i = int.Parse(sValue);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static string GetAppPath()
        {
            string sAppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            return sAppPath;
        }
    }
}
